/*
* Copyright 2009 NOR_/D Labs <http://labs.nortd.com>
*
* This file is part of SceneExpression.
* SceneExpression is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License 
* as published by the Free Software Foundation, either version 3 of 
* the License, or (at your option) any later version. For details
* see <http://www.gnu.org/licenses/>.
*
* * *
* 
*/

#ifndef SX_SLIDER
#define SX_SLIDER


#include <osg/BoundsChecking>
#include <sx/Widget.h>

namespace sx {

class SliderWidget;


class SliderNob: public Widget {
    public:

        osg::ref_ptr<SliderWidget>  _slider;
        std::string  _defaultTypeface;
        osg::ref_ptr<osgText::Text>  _label;
        float _value;
        float _valueMin;
        float _valueMax;
        osg::Vec4 _buttonPressBorderColor;
        osg::Vec4 _buttonPressBorderColorTemp;        
        
        SliderNob( SliderWidget* slider );

        void setValue( float value );
        float getValue();        
        void setLabelColor( float r, float g, float b, float a );
                            
        virtual void reshape();

        bool touchDown( Touch& touch );
        bool touchMove( Touch& touch );
        bool touchUp( Touch& touch );
};


class SliderWidget:  public Widget {
    public:
    
        SliderWidget();

        void setValue( float value );
        float getValue();
        void setValueMin( float min );
        void setValueMax( float max );
        void addEventHandler( SliderHandler* handler );        
        std::vector<SliderHandler*>&  getEventHandlers();        
        
        virtual void reshape();
        virtual void setName( std::string name );
        void setLabelColor( float r, float g, float b, float a );

            
        void update();   //Frame Event    

        // Touch Events
        //
        bool touchDown( Touch& touch );
        bool touchMove( Touch& touch );
        bool touchUp( Touch& touch );        
                
    protected:
        osg::ref_ptr<SliderNob>      _nob;
        std::vector<SliderHandler*>  _handlers;     
        
};


}
#endif